<extend name="Public/base" />

<block name="body">
    <form method="POST" id="list" action="{:U('kcExport')}">
        <!-- 标题栏 -->
        <div class="main-title">
            <h2>
                {$title}
                <a onclick="orderexport();" class="btn confirm btn-default">批量导出</a>
            </h2>
        </div>
        <div class="cf">
                <!--<a class="btn btn-primary" href="{:U('inadd')}">入 库</a>-->
                <!--<a class="btn btn-primary" href="{:U('outadd')}">出 库</a>-->
                <a class="btn btn-warning" href="{:U('checkinventory')}">盘 点</a>
            <div class="search-form fr cf">
                <!--<div style="float: left;height: 100%;padding-top: 5px;padding-right: 20px;">-->
                    <!--展示0库存商品<input type="checkbox" <?php echo $cnt==-1?checked:'' ?>  class=""  name="cnt" value=-1 >-->
                <!--</div>-->
                <div class="sleft">
                    <select name="classify" class="search-input" style="height: 30px;width:120px">
                        <option value="">所有货别</option>
                        <volist name="_classify" id="vo">
                           <option value="{$vo.classify_no}" {$classify==$vo['classify_no']?'selected':''}>{$vo.classify}</option>
                        </volist>
                    </select>
                </div>
                <div class="sleft">
                    <input type="text" name="pname" class="input search-input" value="{:I('pname')}" placeholder="请输入商品名称" style="height: 30px;width:140px">
                </div>
                <div class="sleft">
                    <input type="text" name="BIN" class="search-input" value="{:I('BIN')}" placeholder="请输入编码">
                    <a class="sch-btn" href="javascript:;" id="search" url="{:U('inventoryrealtime')}"><i class="btn-search"></i></a>
                </div>
            </div>
        </div>
        <!-- 数据列表 -->
        <div class="data-table table-striped">
            <table class="">
                <thead>
                    <tr>
                        <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                        <th>商品编码</th>
                        <th>货别</th>
                        <th>商品名称</th>
                        <th>规格</th>
                        <th>库存</th>
                        <th>批次</th>
                        <th>最新盘点</th>
                        <th>上次修改</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                <notempty name="_list">
                    <volist name="_list" id="vo">
                        <tr>
                            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
                            <td>{$vo.BIN}</td>
                            <td>{$vo.BIN|get_no_by_tag=###,'classify_no'|get_name_by_id=###,'Material_classify','classify_no','classify'}</td>
                            <td>{$vo.pname}</td>
                            <td>{$vo.BIN|get_name_by_id=###,'Material_product','BIN','spec'}</td>
                            <td>{$vo.cnt}</td>
                            <td>
                                <a class="btn btn-info" role="button" data-toggle="collapse" href="#{$vo.BIN}" aria-expanded="false" aria-controls="{$vo.BIN}">
                                   {:count($vo['batchLists'])}
                                </a>
                            </td>
                            <td>{$vo.pd|time_format=###,'Y-m-d'}</td>
                            <td>{$vo.updateAt|time_format=###,'Y-m-d'}</td>
                            <td>
                                <a href="{:U('newcntwarn',array('BIN'=>$vo['BIN']))}" class="btn btn-warning">库存预警</a>
                                <if  condition="in_array($vo['BIN'],$hidearr)">
                                    <a href="{:U('show')}&BIN={$vo.BIN}" class="ajax-get btn btn-success">手机端显示</a>
                                    <else/>
                                    <a href="{:U('hide')}&BIN={$vo.BIN}" class="ajax-get btn btn-primary">手机端隐藏</a>
                                </if>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="10">
                                <div class="collapse" id="{$vo.BIN}">
                                    <div class="well" style="margin: 0;padding: 0;">
                                        <table class="table" style="margin-bottom: 0;">
                                            <volist name="vo.batchLists" id="vl">
                                                <tr>
                                                    <td>├</td>
                                                    <td><a href="{:U('inventory/warn')}&warn_batch={$vl.warn_batch}&BIN={$vl.BIN}">{$vl.warn_batch}</a></td>
                                                    <td>{$vl.cnt}</td>
                                                    <td>
                                                        <if condition="$vl['per2_time'] egt $today">
                                                            <span class="btn btn-success">销售期</span>
                                                        </if>
                                                        <if condition="$vl['per2_time'] lt $today">
                                                            <span class="btn btn-danger">过期</span>
                                                        </if>
                                                    </td>
                                                    <td>
                                                        {:(strtotime($vl['per2_time'])-strtotime($today))/86400}
                                                    </td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                </tr>
                                            </volist>
                                        </table>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </volist>
                    <else/>
                    <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
                </notempty>
                </tbody>
            </table>
        </div>
        <div class="page">
            {$_page}
        </div>
    </form>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            var queryselect = $('.search-form').find('select').serialize();
            
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            queryselect = queryselect.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            queryselect = queryselect.replace(/^&/g, '');
            
            if (url.indexOf('?') > 0) {
                url += '&' + query;
                url += '&' + queryselect;
            } else {
                url += '?' + query;
                url += '?' + queryselect;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        
        function orderexport(){
            var r=confirm("确定是否导出!");
            if (r==true)
            {
              $('#list').submit();
            }
        }
        //导航高亮
        highlight_subnav('{:U('Inventory/inventoryrealtime')}');
    </script>
</block>
